@page "/jsonparse"
@using System.Text.Json
@using JT808Protocol.Abstracts;
@inject JsonSerializerOptions serializeOptions
@inject IJT808Parser jtSerialize

<label>808协议原始数据：</label>
<input type="text" class="form-control" @bind="HexInput" />
<button class="btn" @onclick="btnParse_OnClick">解析</button>
<button class="btn" @onclick="()=>HexInput=string.Empty">清空</button>

<div style="padding: 3rem; font-size: 16px;">
<textarea name="" id="myTextarea" cols="30" rows="10">@JsonOutput</textarea>
</div>

@code
{
    [Parameter]
    public string HexInput { get; set; }

    [Parameter]
    public string JsonOutput { get; set; }

    public void btnParse_OnClick()
    {
        if (string.IsNullOrEmpty(HexInput))
            return;

        var package = jtSerialize.Parse(HexInput);
        JsonOutput = JsonSerializer.Serialize(package, serializeOptions);
    }
}